﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:wpf="clr-namespace:ViewOnCore.Helper.WPF;assembly=ViewOnCore"
    xmlns:host="clr-namespace:ViewOnCore.HostContract;assembly=ViewOnCore">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="..\Shared.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="ExpandCollapseToggleStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Grid
								Width="15"
								Height="13"
								Background="Transparent">
                        <Path x:Name="ExpandPath"
									  HorizontalAlignment="Left"
									  VerticalAlignment="Center"
									  Margin="1,1,1,1"
									  Fill="{DynamicResource VOColorIcon}"
									  Data="M 4 0 L 8 4 L 4 8 Z"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked"
										 Value="True">
                            <Setter Property="Data"
											  TargetName="ExpandPath"
											  Value="M 0 4 L 8 4 L 4 8 Z"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="TreeViewItem.TransparentWithEffect4" TargetType="{x:Type TreeViewItem}">
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TreeViewItem}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <ToggleButton
									  x:Name="Expander"
									  Style="{StaticResource ExpandCollapseToggleStyle}"
									  IsChecked="{Binding Path=IsExpanded,RelativeSource={RelativeSource TemplatedParent}}"
									  ClickMode="Press"/>
                        <Border Name="highlight" Grid.Column="1" Margin="2,2,2,2" BorderBrush="{DynamicResource VOColor14}" CornerRadius="1" BorderThickness="1" Background="{StaticResource FlatButtonOver}" Opacity="0">
                            <Border.BitmapEffect>
								<OuterGlowBitmapEffect GlowColor="{Binding Source={x:Static host:Host.UIService}, Path=GlowColors.VOGColor1A}" GlowSize="2" Noise="0" Opacity="0.5" />
							</Border.BitmapEffect>
                        </Border>
                        <Border
												  Name="Border"
												  Grid.Column="1"
												  Margin="2,2,2,2"
												  CornerRadius="1">
                            <ContentPresenter
														  x:Name="PART_Header"
														  ContentSource="Header"
														  Margin="2,2,2,2"
														  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
                                <ContentPresenter.BitmapEffect>
                                    <OuterGlowBitmapEffect x:Name="HoverEffect" GlowColor="{Binding Source={x:Static host:Host.UIService}, Path=GlowColors.VOGColor1A}" GlowSize="0" Noise="0" Opacity="0.5" />
                                </ContentPresenter.BitmapEffect>
                            </ContentPresenter>
                            <Border.Triggers>
                                <EventTrigger RoutedEvent="Mouse.MouseEnter">
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <Storyboard.Children>
                                                <DoubleAnimation To="0.7" Duration="00:00:00.2000000" Storyboard.TargetName="highlight" Storyboard.TargetProperty="Opacity" />
                                            </Storyboard.Children>
                                        </Storyboard>
                                    </BeginStoryboard>
                                </EventTrigger>
                                <EventTrigger RoutedEvent="Mouse.MouseLeave">
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <Storyboard.Children>
                                                <DoubleAnimation To="0" Duration="00:00:00.2000000" Storyboard.TargetName="highlight" Storyboard.TargetProperty="Opacity" />
                                            </Storyboard.Children>
                                        </Storyboard>
                                    </BeginStoryboard>
                                </EventTrigger>
                            </Border.Triggers>
                        </Border>
                        <ItemsPresenter
									  x:Name="ItemsHost"
									  Grid.Row="1"
									  Grid.Column="1"
									  Grid.ColumnSpan="2" Margin="-3,0,0,0"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsExpanded" Value="false">
                            <Setter TargetName="ItemsHost" Property="Visibility" Value="Collapsed"/>
                        </Trigger>
                        <Trigger Property="HasItems" Value="false">
                            <Setter TargetName="Expander" Property="Visibility" Value="Hidden"/>
                        </Trigger>
                        <Trigger Property="IsSelected" Value="true">
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource VOColor02}"/>
                        </Trigger>
                        <EventTrigger RoutedEvent="Mouse.MouseEnter">
                            <BeginStoryboard>
                                <Storyboard>
                                    <Storyboard.Children>
                                        <DoubleAnimation To="4" Duration="00:00:00.1" Storyboard.TargetName="HoverEffect" Storyboard.TargetProperty="GlowSize" />
                                    </Storyboard.Children>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                        <EventTrigger RoutedEvent="Mouse.MouseLeave">
                            <BeginStoryboard>
                                <Storyboard>
                                    <Storyboard.Children>
                                        <DoubleAnimation To="0" Duration="00:00:00.1" Storyboard.TargetName="HoverEffect" Storyboard.TargetProperty="GlowSize" />
                                    </Storyboard.Children>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>